<script>
	import {
		mapGetters,
		mapMutations,
		mapActions
	} from 'vuex'

	export default {
		onLaunch() {
			//#ifdef APP-PLUS
			// plus.screen.lockOrientation('landscape-primary'); // 强制横屏
			plus.screen.lockOrientation('portrait-primary'); // 强制竖屏
			//#endif			
		},
		onShow() {
			console.log("app onShow")
			this.getDeviceId()
			this.getAppInfo()
			this.$nextTick(() => {
				// //动向推送开关
				let pushSwitch = uni.getStorageSync("pushSwitch")
				if (pushSwitch) {
					this.updataPushSwitch(pushSwitch);
				} else {
					this.updataPushSwitch(false);
				}
			})
		},
		onHide() {
			console.log("app onHide")
		},
		methods: {
			...mapMutations([
				"updataAppInfo",
				"updataAppMessage",
				"updateAccess_token",
				"updataDeviceId",
				"updataOaid",
				"updataOsVersion",
				"updataPushSwitch"
			]),
			...mapActions([]),
			getAppInfo() {
				let appMessage = {
					// pack:"com.yxsj.scanfile",
					pack: "com.hxcy.filescan",
					brand: 'vivo',
					version: "1.0.0",
				}
				this.updataAppMessage(appMessage)
				this.$http.post("/api/app/info", appMessage).then((res) => {
					if (res.code == 0) {
						this.updataAppInfo(res.data)
					}
				})
			},

			getDeviceId() {
				let this_ = this
				let deviceId = uni.getStorageSync("deviceId")
				if (deviceId) {
					deviceId = JSON.parse(deviceId)
					this.updataDeviceId(deviceId)
				} else {
					uni.getSystemInfo({
						success: function(res) {
							uni.setStorageSync("deviceId", JSON.stringify(res.deviceId))
							uni.setStorageSync("osVersion", JSON.stringify(res.osVersion))
							this_.updataOsVersion(res.osVersion)
							this_.updataDeviceId(res.deviceId)
							this_.updataOaid(res.oaid)
						}
					})
				}
			},

		}

	}
</script>

<style lang="scss">
	.page {
		background-color: rgba(28, 28, 28, 1);
	}

	@font-face {
		font-family: 'SourceHanSansCN';
		src: url('./static/font/SourceHanSansCN-Medium.otf');
	}

	@font-face {
		font-family: 'AlibabaPuHuiTi_20';
		src: url('./static/font/Alibaba-PuHuiTi-Regular.otf');
	}
</style>